namespace Juli.Mes.Permissions
{
    public class MesPermissionDefinitionProvider : PermissionDefinitionProvider
    {
        public override void Define(IPermissionDefinitionContext context)
        {
            var basic = context.AddGroup(MesPermissions.BasicGroupName, L("BasicData"));
            var productManage = basic.AddPermission(MesPermissions.ProductManagement.Default, L("ProductManage"));
            productManage.AddChild(MesPermissions.ProductManagement.Product.Create, L("Permission:Create"));
            productManage.AddChild(MesPermissions.ProductManagement.Product.Update, L("Permission:Update"));
            productManage.AddChild(MesPermissions.ProductManagement.Product.Delete, L("Permission:Delete"));
            productManage.AddChild(MesPermissions.ProductManagement.Product.Query, L("Permission:Query"));

            var customerManage = basic.AddPermission(MesPermissions.CustomerManagement.Default, L("CustomerManage"));
            customerManage.AddChild(MesPermissions.CustomerManagement.Customer.Create, L("Permission:Create"));
            customerManage.AddChild(MesPermissions.CustomerManagement.Customer.Update, L("Permission:Update"));
            customerManage.AddChild(MesPermissions.CustomerManagement.Customer.Delete, L("Permission:Delete"));
            customerManage.AddChild(MesPermissions.CustomerManagement.Customer.Query, L("Permission:Query"));

            var assets = context.AddGroup(MesPermissions.AssetsManagementGroupName, L("AssetsManagement"));

            var stoveManage = assets.AddPermission(MesPermissions.StoveManagement.Default, L("StoveManage"));
            stoveManage.AddChild(MesPermissions.StoveManagement.Stove.Create, L("Permission:Create"));
            stoveManage.AddChild(MesPermissions.StoveManagement.Stove.Update, L("Permission:Update"));
            stoveManage.AddChild(MesPermissions.StoveManagement.Stove.Delete, L("Permission:Delete"));
            stoveManage.AddChild(MesPermissions.StoveManagement.Stove.Query, L("Permission:Query"));

            var vehicleManage = assets.AddPermission(MesPermissions.VehicleManagement.Default, L("VehicleManage"));
            vehicleManage.AddChild(MesPermissions.VehicleManagement.Vehicle.Create, L("Permission:Create"));
            vehicleManage.AddChild(MesPermissions.VehicleManagement.Vehicle.Update, L("Permission:Update"));
            vehicleManage.AddChild(MesPermissions.VehicleManagement.Vehicle.Delete, L("Permission:Delete"));
            vehicleManage.AddChild(MesPermissions.VehicleManagement.Vehicle.Query, L("Permission:Query"));

            var ladleManage = assets.AddPermission(MesPermissions.LadleManagement.Default, L("LadleManage"));
            ladleManage.AddChild(MesPermissions.LadleManagement.Ladle.Create, L("Permission:Create"));
            ladleManage.AddChild(MesPermissions.LadleManagement.Ladle.Update, L("Permission:Update"));
            ladleManage.AddChild(MesPermissions.LadleManagement.Ladle.Delete, L("Permission:Delete"));
            ladleManage.AddChild(MesPermissions.LadleManagement.Ladle.Query, L("Permission:Query"));

            var production = context.AddGroup(MesPermissions.ProductionManagementGroupName, L("ProductionManagement"));

            var planManage = production.AddPermission(MesPermissions.PlanManagement.Default, L("PlanManage"));
            planManage.AddChild(MesPermissions.PlanManagement.Plan.Create, L("Permission:Create"));
            planManage.AddChild(MesPermissions.PlanManagement.Plan.Update, L("Permission:Update"));
            planManage.AddChild(MesPermissions.PlanManagement.Plan.Delete, L("Permission:Delete"));
            planManage.AddChild(MesPermissions.PlanManagement.Plan.Query, L("Permission:Query"));
            planManage.AddChild(MesPermissions.PlanManagement.Plan.Sync, L("PlanManage:Sync"));
            planManage.AddChild(MesPermissions.PlanManagement.Plan.Upload, L("PlanManage:Upload"));

        }

        private static LocalizableString L(string name)
        {
            return LocalizableString.Create<MesResource>(name);
        }
    }
}